import 'difficulty_progress.dart';

class MusicProgress {
  final String songId;
  final DifficultyProgress spbProgress;
  final DifficultyProgress spnProgress;
  final DifficultyProgress sphProgress;
  final DifficultyProgress spaProgress;
  final DifficultyProgress splProgress;
  final DifficultyProgress dpbProgress;
  final DifficultyProgress dpnProgress;
  final DifficultyProgress dphProgress;
  final DifficultyProgress dpaProgress;
  final DifficultyProgress dplProgress;

  MusicProgress({
    required this.songId,
    required this.spbProgress,
    required this.spnProgress,
    required this.sphProgress,
    required this.spaProgress,
    required this.splProgress,
    required this.dpbProgress,
    required this.dpnProgress,
    required this.dphProgress,
    required this.dpaProgress,
    required this.dplProgress
  });

  MusicProgress.def({required this.songId})
    : spbProgress = DifficultyProgress(),
      spnProgress = DifficultyProgress(),
      sphProgress = DifficultyProgress(),
      spaProgress = DifficultyProgress(),
      splProgress = DifficultyProgress(),
      dpbProgress = DifficultyProgress(),
      dpnProgress = DifficultyProgress(),
      dphProgress = DifficultyProgress(),
      dpaProgress = DifficultyProgress(),
      dplProgress = DifficultyProgress();


  MusicProgress.fromJson(Map<String, dynamic> json)
    : songId = json['songId'] as String,
      spbProgress = json['spbProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['spbProgress'] as Map<String, dynamic>),
      spnProgress = json['spnProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['spnProgress'] as Map<String, dynamic>),
      sphProgress = json['sphProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['sphProgress'] as Map<String, dynamic>),
      spaProgress = json['spaProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['spaProgress'] as Map<String, dynamic>),
      splProgress = json['splProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['splProgress'] as Map<String, dynamic>),
      dpbProgress = json['dpbProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['dpbProgress'] as Map<String, dynamic>),
      dpnProgress = json['dpnProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['dpnProgress'] as Map<String, dynamic>),
      dphProgress = json['dphProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['dphProgress'] as Map<String, dynamic>),
      dpaProgress = json['dpaProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['dpaProgress'] as Map<String, dynamic>),
      dplProgress = json['dplProgress'] == null
          ? DifficultyProgress() : DifficultyProgress.fromJson(json['dplProgress'] as Map<String, dynamic>);

  Map<String, dynamic> toJson() => {
    'songId': songId,
    'spbProgress': spbProgress?.toJson(),
    'spnProgress': spnProgress?.toJson(),
    'sphProgress': sphProgress?.toJson(),
    'spaProgress': spaProgress?.toJson(),
    'splProgress': splProgress?.toJson(),
    'dpbProgress': dpbProgress?.toJson(),
    'dpnProgress': dpnProgress?.toJson(),
    'dphProgress': dphProgress?.toJson(),
    'dpaProgress': dpaProgress?.toJson(),
    'dplProgress': dplProgress?.toJson()
  };
}
